package com.sky.yipinyoufujava.mapper;
import com.sky.yipinyoufujava.pojo.WxUserInfo;
import com.sky.yipinyoufujava.pojo.from.LoginForm;
import com.sky.yipinyoufujava.pojo.from.ModifyPasswordForm;
import com.sky.yipinyoufujava.pojo.from.RegisterForm;
import com.sky.yipinyoufujava.pojo.User;
import org.apache.ibatis.annotations.*;

@Mapper
public interface LoginMapper{
    /**
     * 查询用户列表
     * @return
     */
    @Select("select * from user where username = #{username} and password = #{password}")
    User getUser(LoginForm loginForm);


    /**
     * 查询是否存在这个用户
     * @param name
     * @return
     */
    @Select("select * from user where username = #{name} ")
    Short queryUser(String name);


    @Insert("INSERT INTO user (username, password, email) VALUES (#{username}, #{password}, #{email})")
    void registerUser(RegisterForm registerForm);



    @Select("select * from user where id = #{id} ")
    User queryUserId(Object id);




    @Update("UPDATE user SET password = #{modifyPasswordForm.newPassword} WHERE id = #{id}")
    void modifyPassword(@Param("id")int id,@Param("modifyPasswordForm") ModifyPasswordForm modifyPasswordForm);

    void updataUserInfo(User user);


    @Select("select * from user where phone = #{phone}")
    User queryUserByOpenId(String phone);


    void wxRegister(WxUserInfo wxUserInfo);
}
